package com.jxw.adapter;

import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.view.ViewGroup;
import com.jxw.launcher.BaseFragment;
import java.util.List;

/* loaded from: classes.dex */
public class SubjectViewPagerAdapter extends FragmentPagerAdapter {
    private FragmentManager fm;
    private List<BaseFragment> mfragmentList;

    @Override // android.support.v4.view.PagerAdapter
    public int getItemPosition(Object obj) {
        return -2;
    }

    public SubjectViewPagerAdapter(FragmentManager fragmentManager, List<BaseFragment> list) {
        super(fragmentManager);
        this.mfragmentList = list;
        this.fm = fragmentManager;
    }

    @Override // android.support.v4.app.FragmentPagerAdapter
    public BaseFragment getItem(int i) {
        return this.mfragmentList.get(i);
    }

    @Override // android.support.v4.view.PagerAdapter
    public int getCount() {
        return this.mfragmentList.size();
    }

    @Override // android.support.v4.app.FragmentPagerAdapter, android.support.v4.view.PagerAdapter
    public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
        super.destroyItem(viewGroup, i, obj);
    }

    @Override // android.support.v4.app.FragmentPagerAdapter, android.support.v4.view.PagerAdapter
    public Object instantiateItem(ViewGroup viewGroup, int i) {
        return super.instantiateItem(viewGroup, i);
    }

    public void setData(List<BaseFragment> list) {
        this.mfragmentList = list;
        notifyDataSetChanged();
    }

    public void setFragments(List<BaseFragment> list) {
        if (this.mfragmentList != null) {
            FragmentTransaction beginTransaction = this.fm.beginTransaction();
            for (BaseFragment baseFragment : this.mfragmentList) {
                beginTransaction.remove(baseFragment);
            }
            try {
                beginTransaction.commit();
            } catch (Exception unused) {
            }
            this.fm.executePendingTransactions();
        }
        this.mfragmentList = list;
        notifyDataSetChanged();
    }
}
